import { axios } from '@/utils/request'

/**
 * 交易记录管理
 */

export function selectPage (parameter) {
  if (parameter.beginTime != undefined) {
    parameter.beginTime = parameter.beginTime.format('YYYY-MM-DD')
  }
  if (parameter.endTime != undefined) {
    parameter.endTime = parameter.endTime.format('YYYY-MM-DD')
  }
  return axios({
    url: '/shop/trade/selectPage',
    method: 'post',
    params: parameter
  })
}

export function doNotice (parameter) {
  return axios({
    url: '/shop/trade/doNotice',
    method: 'post',
    params: parameter
  })
}

export function doBudan (parameter) {
  return axios({
    url: '/shop/trade/doBudan',
    method: 'post',
    params: parameter
  })
}

export function exportExcel(parameter) {
  return axios({
    url: '/shop/trade/exportExcel',
    method: 'post',
    responseType:'blob',
    params: parameter
  })
}

export function statisticsCustomerPage (parameter) {
  return axios({
    url: '/shop/trade/statisticsCustomerPage',
    method: 'post',
    params: parameter
  })
}

export function statisticsMerchantPage (parameter) {
  return axios({
    url: '/shop/trade/statisticsMerchantPage',
    method: 'post',
    params: parameter
  })
}

export function beginProfit (parameter) {
  return axios({
    url: '/shop/trade/' + parameter + '/beginProfit',
    method: 'get'
  })
}

export function endProfit (parameter) {
  return axios({
    url: '/shop/trade/' + parameter + '/endProfit',
    method: 'get'
  })
}
export function refund(tradeId) {
  return axios({
    url: '/shop/trade/refund',
    method: 'post',
    params: {tradeId:tradeId}
  })
}